<?php
/**
 * Description of Cookie
 * @author dongtao@xiaomi.com
 */

class Cookie {
    //过期时间
    private $_expire = 604800;  //一周
    
    //路径
    private $_path = null;

    //域名
    private $_domain = null;
    
    public static function getInstance(){
        return new static();
    }

    //设置cookie
    public function set($name,$value){
        setcookie($name, $value, time()+$this->_expire, $this->_path, $this->_domain);
    }
    
    //获取cookie
    public function get($name){
        return isset($_COOKIE[$name])?$_COOKIE[$name]:NULL;
    }
    
    //删除cookie
    public function del($name){
        if(isset($_COOKIE[$name])){
            setcookie($name, NULL, time()-3600);
            unset($_COOKIE[$name]);
        }
    }
    
    //清空cookie
    public function clear(){
        
    }
}
